package main
import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/order"
	"github.com/streadway/amqp"
)

/**
 * @className pinganThirdPay
 * 支付成功，将符合要的订单信息加入到平安第三方在途充值任务表中
 * @author liyang<654516092@qq.com>
 * @date 2021/4/27 16:09
 */

//订单支付成功，业务处理
func main() {
	mOrder := new(order.PingAn).Init()
	defer mOrder.Close()
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("order.log.pinganThirdOrderPaySuc"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("order.queue.pinganThirdOrderPaySuc"), func(msg amqp.Delivery) {
		orderSn := string(msg.Body)
		var reply bool
		err := mOrder.PaySuc(context.Background(), &orderSn, &reply)
		if err != nil {
			utils.Logerr.Printf("平安银行第三方在途充值-新增任务表失败,orderSn:%s, err:%s", orderSn, err)
		}
	})
	if err != nil {
		utils.Logerr.Printf("平安银行第三方在途充值-新增任务表失败，err: %s", err.Error())
	}
}
